clear all;
clc;
! head -1 ../../../data/nlsy97/cleaned/y97_tscrGPA.csv
A=importdata('../../../data/nlsy97/cleaned/y97_tscrGPA.csv');
data  = A.data;
[N,KK]=size(A.data)
T  = 19;
K0 = 69;
K1 = (KK-K0)/T;
%% read in constant (time-invarying variables)
cons_vars = data(:,1:K0);
ID                         = data(:,1 );
male                       = data(:,2 );
black                      = data(:,3 );
hispanic                   = data(:,4 );
AFQT                       = data(:,5 );
ASVABmath                  = data(:,6 );
ASVABverb                  = data(:,7 );
predSATmathZ               = data(:,8 );
predSATverbZ               = data(:,9 );
efc                        = data(:,10);
asvabAR                    = data(:,11);
asvabCS                    = data(:,12);
asvabMK                    = data(:,13);
asvabNO                    = data(:,14);
asvabPC                    = data(:,15);
asvabWK                    = data(:,16);
SATmath                    = data(:,17);
SATverb                    = data(:,18);
numAPs                     = data(:,19);
lateForSchoolNoExcuse      = data(:,20);
breakRulesRegularly        = data(:,21);
R1ExtraClass               = data(:,22);
R1WeekdaysExtraClass       = data(:,23);
HrsExtraClass              = data(:,24);
tookClassDuringBreak       = data(:,25);
reasonTookClassDuringBreak = data(:,26);
highStandardsWork          = data(:,27);
doMoreThanExpected         = data(:,28);
pctChanceWork20Hrs30       = data(:,29);
parPctChanceWork20Hrs30    = data(:,30);
tui4imp                    = data(:,31);
grant4pr                   = data(:,32);
grant4idx                  = data(:,33);
grant4RMSE                 = data(:,34);
loan4pr                    = data(:,35);
loan4idx                   = data(:,36);
loan4RMSE                  = data(:,37);
tui2imp                    = data(:,38);
grant2pr                   = data(:,39);
grant2idx                  = data(:,40);
grant2RMSE                 = data(:,41);
loan2pr                    = data(:,42);
loan2idx                   = data(:,43);
loan2RMSE                  = data(:,44);
ParTrans2RMSE              = data(:,45);
ParTrans4RMSE              = data(:,46);
loan18_4pr                 = data(:,47);
loan18_4idx                = data(:,48);
loan18_4RMSE               = data(:,49);
loan18_2pr                 = data(:,50);
loan18_2idx                = data(:,51);
loan18_2RMSE               = data(:,52);
E_loan4_18                 = data(:,53);
E_loan2_18                 = data(:,54);
BA_year                    = data(:,55);
AA_year                    = data(:,56);
BA_month                   = data(:,57);
AA_month                   = data(:,58);
CC_DO_SO                   = data(:,59);
Grades_HS_best             = data(:,60);
Peduc                      = data(:,61);
m_Peduc                    = data(:,62);
Parent_college             = data(:,63);
FamIncAsTeen               = data(:,64);
m_FamIncAsTeen             = data(:,65);
finalMajorSci              = data(:,66);
finalMajorSciA             = data(:,67);
finalMajorSciB             = data(:,68);
finalMajor                 = data(:,69);
%% read in time-varying variables
chng_vars = reshape( data(:,K0+1:end),N,K1,T);
year                  = squeeze(chng_vars(:,1 ,:)); 
choice                = squeeze(chng_vars(:,2 ,:)); 
age                   = squeeze(chng_vars(:,3 ,:)); 
cum_2yr               = squeeze(chng_vars(:,4 ,:)); 
cum_4yr               = squeeze(chng_vars(:,5 ,:)); 
grad_2yr              = squeeze(chng_vars(:,6 ,:)); 
grad_4yr              = squeeze(chng_vars(:,7 ,:)); 
grades                = squeeze(chng_vars(:,8 ,:)); 
log_wage              = squeeze(chng_vars(:,9 ,:)); 
log_comp              = squeeze(chng_vars(:,10,:)); 
log_wageJobMain       = squeeze(chng_vars(:,11,:)); 
log_compJobMain       = squeeze(chng_vars(:,12,:)); 
hours_per_week_Oct    = squeeze(chng_vars(:,13,:));
weeks_worked_Oct      = squeeze(chng_vars(:,14,:));
anyFlag               = squeeze(chng_vars(:,15,:));
anyFlagFemale         = squeeze(chng_vars(:,16,:));
in_grad_school        = squeeze(chng_vars(:,17,:));
scienceMajor          = squeeze(chng_vars(:,18,:));
scienceMajorA         = squeeze(chng_vars(:,19,:));
scienceMajorB         = squeeze(chng_vars(:,20,:));
DKmajor               = squeeze(chng_vars(:,21,:));
missingMajor          = squeeze(chng_vars(:,22,:));
otherMajor            = squeeze(chng_vars(:,23,:));
otherMajorA           = squeeze(chng_vars(:,24,:));
otherMajorB           = squeeze(chng_vars(:,25,:));
major                 = squeeze(chng_vars(:,26,:));
idxParTrans4          = squeeze(chng_vars(:,27,:));
idxParTrans2          = squeeze(chng_vars(:,28,:));
prParTrans2           = squeeze(chng_vars(:,29,:));
prParTrans4           = squeeze(chng_vars(:,30,:));
E_ParTrans2           = squeeze(chng_vars(:,31,:));
E_ParTrans4           = squeeze(chng_vars(:,32,:));
whiteCollar           = squeeze(chng_vars(:,33,:));
choice15stata         = squeeze(chng_vars(:,34,:));
choice15Astata        = squeeze(chng_vars(:,35,:));
choice15Bstata        = squeeze(chng_vars(:,36,:));
choice25stata         = squeeze(chng_vars(:,37,:));
clear A data chng_vars cons_vars K0 K1 KK N T
save ../../../data/nlsy97/cleaned/wide_data20220401_tscrGPA.mat

clear all;
clc;
A=importdata('../../../data/nlsy97/cleaned/y97_male_tscrGPA.csv');
data  = A.data;
[N,KK]=size(A.data)
T  = 19;
K0 = 69;
K1 = (KK-K0)/T;
%% read in constant (time-invarying variables)
cons_vars = data(:,1:K0);
ID                         = data(:,1 );
male                       = data(:,2 );
black                      = data(:,3 );
hispanic                   = data(:,4 );
AFQT                       = data(:,5 );
ASVABmath                  = data(:,6 );
ASVABverb                  = data(:,7 );
predSATmathZ               = data(:,8 );
predSATverbZ               = data(:,9 );
efc                        = data(:,10);
asvabAR                    = data(:,11);
asvabCS                    = data(:,12);
asvabMK                    = data(:,13);
asvabNO                    = data(:,14);
asvabPC                    = data(:,15);
asvabWK                    = data(:,16);
SATmath                    = data(:,17);
SATverb                    = data(:,18);
numAPs                     = data(:,19);
lateForSchoolNoExcuse      = data(:,20);
breakRulesRegularly        = data(:,21);
R1ExtraClass               = data(:,22);
R1WeekdaysExtraClass       = data(:,23);
HrsExtraClass              = data(:,24);
tookClassDuringBreak       = data(:,25);
reasonTookClassDuringBreak = data(:,26);
highStandardsWork          = data(:,27);
doMoreThanExpected         = data(:,28);
pctChanceWork20Hrs30       = data(:,29);
parPctChanceWork20Hrs30    = data(:,30);
tui4imp                    = data(:,31);
grant4pr                   = data(:,32);
grant4idx                  = data(:,33);
grant4RMSE                 = data(:,34);
loan4pr                    = data(:,35);
loan4idx                   = data(:,36);
loan4RMSE                  = data(:,37);
tui2imp                    = data(:,38);
grant2pr                   = data(:,39);
grant2idx                  = data(:,40);
grant2RMSE                 = data(:,41);
loan2pr                    = data(:,42);
loan2idx                   = data(:,43);
loan2RMSE                  = data(:,44);
ParTrans2RMSE              = data(:,45);
ParTrans4RMSE              = data(:,46);
loan18_4pr                 = data(:,47);
loan18_4idx                = data(:,48);
loan18_4RMSE               = data(:,49);
loan18_2pr                 = data(:,50);
loan18_2idx                = data(:,51);
loan18_2RMSE               = data(:,52);
E_loan4_18                 = data(:,53);
E_loan2_18                 = data(:,54);
BA_year                    = data(:,55);
AA_year                    = data(:,56);
BA_month                   = data(:,57);
AA_month                   = data(:,58);
CC_DO_SO                   = data(:,59);
Grades_HS_best             = data(:,60);
Peduc                      = data(:,61);
m_Peduc                    = data(:,62);
Parent_college             = data(:,63);
FamIncAsTeen               = data(:,64);
m_FamIncAsTeen             = data(:,65);
finalMajorSci              = data(:,66);
finalMajorSciA             = data(:,67);
finalMajorSciB             = data(:,68);
finalMajor                 = data(:,69);
%% read in time-varying variables
chng_vars = reshape( data(:,K0+1:end),N,K1,T);
year                  = squeeze(chng_vars(:,1 ,:)); 
choice                = squeeze(chng_vars(:,2 ,:)); 
age                   = squeeze(chng_vars(:,3 ,:)); 
cum_2yr               = squeeze(chng_vars(:,4 ,:)); 
cum_4yr               = squeeze(chng_vars(:,5 ,:)); 
grad_2yr              = squeeze(chng_vars(:,6 ,:)); 
grad_4yr              = squeeze(chng_vars(:,7 ,:)); 
grades                = squeeze(chng_vars(:,8 ,:)); 
log_wage              = squeeze(chng_vars(:,9 ,:)); 
log_comp              = squeeze(chng_vars(:,10,:)); 
log_wageJobMain       = squeeze(chng_vars(:,11,:)); 
log_compJobMain       = squeeze(chng_vars(:,12,:)); 
hours_per_week_Oct    = squeeze(chng_vars(:,13,:));
weeks_worked_Oct      = squeeze(chng_vars(:,14,:));
anyFlag               = squeeze(chng_vars(:,15,:));
anyFlagFemale         = squeeze(chng_vars(:,16,:));
in_grad_school        = squeeze(chng_vars(:,17,:));
scienceMajor          = squeeze(chng_vars(:,18,:));
scienceMajorA         = squeeze(chng_vars(:,19,:));
scienceMajorB         = squeeze(chng_vars(:,20,:));
DKmajor               = squeeze(chng_vars(:,21,:));
missingMajor          = squeeze(chng_vars(:,22,:));
otherMajor            = squeeze(chng_vars(:,23,:));
otherMajorA           = squeeze(chng_vars(:,24,:));
otherMajorB           = squeeze(chng_vars(:,25,:));
major                 = squeeze(chng_vars(:,26,:));
idxParTrans4          = squeeze(chng_vars(:,27,:));
idxParTrans2          = squeeze(chng_vars(:,28,:));
prParTrans2           = squeeze(chng_vars(:,29,:));
prParTrans4           = squeeze(chng_vars(:,30,:));
E_ParTrans2           = squeeze(chng_vars(:,31,:));
E_ParTrans4           = squeeze(chng_vars(:,32,:));
whiteCollar           = squeeze(chng_vars(:,33,:));
choice15stata         = squeeze(chng_vars(:,34,:));
choice15Astata        = squeeze(chng_vars(:,35,:));
choice15Bstata        = squeeze(chng_vars(:,36,:));
choice25stata         = squeeze(chng_vars(:,37,:));
clear A data chng_vars cons_vars K0 K1 KK N T
save ../../../data/nlsy97/cleaned/wide_data_male20220401_tscrGPA.mat
